﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Credisoft.Models.Credisoft_DAO;
using Credisoft.Models.Credisoft_BO;
using Credisoft.Models;

namespace Credisoft.Controllers.Settings
{
    public class OperationController : Controller
    {
        //
        // GET: /Operation/

        public ActionResult Operation()
        {
            return View();
        }

        public JsonResult getProfiles()
        {
            SettingsDAO settingsDAO = new SettingsDAO();
            return new JsonResult() { Data = settingsDAO.getProfiles() } ;
        }

        public JsonResult getRulesByProfile(int profileId)
        {
            SettingsDAO settingsDAO = new SettingsDAO();
            return new JsonResult() { Data = settingsDAO.getRulesByProfile(profileId) };
        }

        public JsonResult saveRulesByProfile(List<ApprovalPrivilegeBO> lstRules)
        {
            SettingsDAO settingsDAO = new SettingsDAO();
            foreach( ApprovalPrivilegeBO aprPriv in lstRules ){
                //privilegioaprobacion priAprob = settingsDAO.getRuleByIds(aprPriv.profileId, aprPriv.sectorId, aprPriv.productId);
                //priAprob.montomaximo = (decimal)aprPriv.maximalAmount;
                //priAprob.tasaminima = aprPriv.minimumRate;
                //settingsDAO.updateRule( priAprob );
            }
            return new JsonResult(){ Data = "ok" } ;
        }
    }
}
